################################################################
#                                                              #
#                           Snippets                           #
#                                                              #
################################################################

snippet type "片段类别 Snippet type" b
################################################################
#                                                              #
#`!p
string_length = len(t[1].encode('gbk')); front_num = (62 - string_length) // 2; snip.rv = ' ' * front_num`$1`!p snip.rv = ' ' * (62 - front_num - string_length)`#
#                                                              #
################################################################
$0
endsnippet

snippet gl "全局 Global" b
global ${1:!p}

${2:${VISUAL}}

endglobal
$0
endsnippet

snippet txt "创建上下文 Create Contest" b
context "${1|math,text,chem,inline_math,display_math,comment|}()"
$0
endsnippet

snippet pp "Pre" b
${1|post_jump,pre_expand,post_expand|} "$2"$0
endsnippet

snippet snip "创建片段 Create Snippet" b
snippet ${1:Trigger} "${2:Description}" ${3:w}`!p snip.rv = "r" if (t[1][:1] == "\"" and "r" not in t[3]) else ""`
$4
`echo endsnippet`
$0
endsnippet

snippet rv "返回值 Return" w
snip.rv = 
endsnippet

snippet m "匹配值 Match" w
match.group(${1:1})$0
endsnippet

snippet tab "TabStop" w
t[${1:1}]$0
endsnippet

snippet t "TabStop" w
\${${1:1}:${2:\${VISUAL}}}$0
endsnippet

snippet vis "Visual" w
\${VISUAL}
endsnippet

snippet scr "脚本 Script" w
\`${1:!p} $2\`$0
endsnippet

snippet from "导入 Import" b
from ${1:mdtex.scopes} import ${2:math}
endsnippet

snippet def "定义 Define" b
def $1($2):
    $0
endsnippet

snippet text "文本片段 Text Snippet" b
context "${1:text}()"
snippet ${2:Trigger} "${3:Description}" ${4:w}`!p snip.rv = "r" if (t[2][:1] == "\"" and "r" not in t[4]) else ""`
$5
`echo endsnippet`
$0
endsnippet

snippet math "数学片段 Math Snippet" b
context "${1|math,chem,inline_math,display_math|}()"
snippet ${2:Trigger} "${3:Description}" ${4:w}`!p snip.rv = "r" if (t[2][:1] == "\"" and "r" not in t[4]) else ""`
$5
`echo endsnippet`
$0
endsnippet

priority 1
snippet tt "TabStop" w
$${1:1}$0
endsnippet

snippet scr "脚本 Script" b
\`${1:!p}
$2
\`$0
endsnippet
